package cn.bincker.mybatis.encrypt.utils;

public class NameUtils {
    public static String hump2Snake(String name){
        var result = new StringBuilder();
        var nameCharArr = name.toCharArray();
        for (int i = 0; i < nameCharArr.length; i++) {
            if (i != 0 && Character.isUpperCase(nameCharArr[i])){
                result.append('_').append(Character.toLowerCase(nameCharArr[i]));
            }else{
                result.append(Character.toLowerCase(nameCharArr[i]));
            }
        }
        return result.toString();
    }
}
